﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;

public partial class WebForm1 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string mystr;
        OleDbConnection oc = new OleDbConnection();
        mystr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Access数据库\web.mdb";
        oc.ConnectionString = mystr;
        oc.Open();
        OleDbCommand odm = new OleDbCommand();
        odm.Connection = oc;
        string odmtext;
        odmtext = "select * from zym";
        odm.CommandText = odmtext;
        odm.ExecuteNonQuery();
        OleDbDataReader myread = odm.ExecuteReader();
        List<string> zh = new List<string>();
        List<string> mm = new List<string>();
        while (myread.Read())
        {
            zh.Add((string)myread[1]);
            mm.Add((string)myread[2]);
        }
        
        for (int i = 0; i <= zh.Count - 1; i++)
        {
            
            if (TextBox1.Text == zh[i] && TextBox2.Text == mm[i])
            {
                Response.Write("登录成功");
                break;
            }
            if (i == zh.Count-1)
            {
                Response.Write("登录失败");
            }
           
        }
        //if()
        //{
        //    Response.Write("请检查账号或密码");
        //}
   
    }
}